package com.example.api.dept;

import com.example.springcloud.common.ResponseEntity;
import com.example.springcloud.common.entity.Dept;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 莫磊
 * @date 2025/8/21
 * @description 调用生产者的接口，所以他的请求URI需要和生产者的保持一致
 */
@FeignClient(name = "DEPT-SERVICE", path = "/dept", fallback = DeptApiFallback.class) // 指定注册中心的服务名（spring.application.name）
public interface DeptApi {


    @GetMapping("/getById/{id}")
    ResponseEntity<Dept> getById(@PathVariable("id") Long id);

    @PostMapping("/addDept")
    ResponseEntity<Dept> addDept(Dept dept);

    @GetMapping("/findByDnameLike/{dname}")
    ResponseEntity<List<Dept>> findByDnameLike(@PathVariable("dname") String dname);

    @GetMapping("/findByDeptno/{deptno}")
    ResponseEntity<List<Dept>> findByDeptno(@PathVariable("deptno") String deptno);

}
